//
//  ViewController.m
//  UI_08_senderData ___delegate
//
//  Created by dllo on 16/3/19.
//  Copyright © 2016年 XWH. All rights reserved.
//

#import "ViewController.h"
#import "RootViewController.h"
@interface ViewController ()<RootViewControllerDelegate>
@property (nonatomic, retain) UILabel *label;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.translucent = NO;
    self.navigationItem.title = @"首页";
    self.view.backgroundColor = [UIColor whiteColor];
    
   _label  = [[UILabel alloc] initWithFrame:CGRectMake(100, 50, 200, 30)];
    
    _label.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:_label];
    
    
    UIButton *buttonOfNext = [UIButton buttonWithType:UIButtonTypeSystem];
    buttonOfNext.frame = CGRectMake(150, 100, 100, 30);
    
    [buttonOfNext setTitle:@"NEXT" forState:UIControlStateNormal];
    buttonOfNext.backgroundColor = [UIColor greenColor];
    [buttonOfNext addTarget:self action:@selector(buttionOfNext:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:buttonOfNext];
    
}

-(void)buttionOfNext:(UIButton *)sender{
    
    RootViewController *rootView = [[RootViewController alloc] init];
    rootView.rootDelegate = self;
    
    
    CATransition *transition = [CATransition animation];
    transition.duration = 1;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
    transition.type = kCATransitionFade;
    
    
    [self.navigationController.view.layer addAnimation:transition forKey:nil];
    [[self navigationController] pushViewController:rootView animated:NO];
    
}

-(void)changeValue:(NSString *)text{
    _label.text = text;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
